
// NOTE: 水动力学模型数据
export class HydrodynamicData {
    constructor( 
        i: number = 0,
        j: number = 0,
        layer: number = 0,
        totalFlux: number = 0,
        waterLevel: number = 0,
        waterDepth: number = 0,
        USpeed: number = 0,
        VSpeed: number = 0,
        WSpeed: number = 0,
        flux: number = 0,
        temperature: number = 0,
        salinity: number = 0,
        colorants: number = 0,
        X: number | null = null, // 可以根据实际需要定义类型，这里假设为number或null
        Y: number | null = null, // 可以根据实际需要定义类型，这里假设为number或null
        Z: number | null = null  // 可以根据实际需要定义类型，这里假设为number或null
    ) {
        this.i = i;
        this.j = j;
        this.layer = layer;
        this.totalFlux = totalFlux;
        this.waterLevel = waterLevel;
        this.waterDepth = waterDepth;
        this.USpeed = USpeed;
        this.VSpeed = VSpeed;
        this.WSpeed = WSpeed;
        this.flux = flux;
        this.temperature = temperature;
        this.salinity = salinity;
        this.colorants = colorants;
        this.X = X;
        this.Y = Y;
        this.Z = Z;
    }
 
    // 类型注解可以进一步添加到类的属性上，如果需要的话
    i: number;
    j: number;
    layer: number;
    totalFlux: number;
    waterLevel: number;
    waterDepth: number;
    USpeed: number;
    VSpeed: number;
    WSpeed: number;
    flux: number;
    temperature: number;
    salinity: number;
    colorants: number;
    X: number | null;
    Y: number | null;
    Z: number | null;
}

// 父类 WaterDataWithIndex
export class WaterDataWithIndex {
    constructor(
        public index: number = 0,
        public i: number = 0,
        public j: number = 0,
        public layer: number = 0,
        public X: number | null = null,
        public Y: number | null = null,
        public Z: number | null = null
    ) {}

    // 子类中可以重写这个方法，或者直接使用父类方法
    toString(): string {
        return `WaterDataWithIndex {
            Index: ${this.index},
            Grid(i, j): (${this.i}, ${this.j}),
            Layer: ${this.layer},
            Position(X, Y, Z): (${this.X}, ${this.Y}, ${this.Z})
        }`;
    }
}


// NOTE: 带索引的水动力学模型数据
// 水动力学模型数据类，继承自 WaterDataWithIndex
export class HydrodynamicDataWithIndex extends WaterDataWithIndex {
    constructor(
        index: number = 0,
        i: number = 0,
        j: number = 0,
        layer: number = 0,
        totalFlux: number = 0,
        waterLevel: number = 0,
        waterDepth: number = 0,
        USpeed: number = 0,
        VSpeed: number = 0,
        WSpeed: number = 0,
        flux: number = 0,
        temperature: number = 0,
        salinity: number = 0,
        colorants: number = 0,
        X: number | null = null,
        Y: number | null = null,
        Z: number | null = null
    ) {
        super(index, i, j, layer, X, Y, Z); // 调用父类构造函数
        this.totalFlux = totalFlux;
        this.waterLevel = waterLevel;
        this.waterDepth = waterDepth;
        this.USpeed = USpeed;
        this.VSpeed = VSpeed;
        this.WSpeed = WSpeed;
        this.flux = flux;
        this.temperature = temperature;
        this.salinity = salinity;
        this.colorants = colorants;
    }
    public totalFlux: number;
    public waterLevel: number;
    public waterDepth: number;
    public USpeed: number;
    public VSpeed: number;
    public WSpeed: number;
    public flux: number;
    public temperature: number;
    public salinity: number;
    public colorants: number;

    toString(): string {
        return `HydrodynamicDataWithIndex {
            ${super.toString()},
            Total Flux: ${this.totalFlux.toFixed(2)},
            Water Level: ${this.waterLevel.toFixed(2)} m,
            Water Depth: ${this.waterDepth.toFixed(2)} m,
            U Speed: ${this.USpeed.toFixed(2)} m/s,
            V Speed: ${this.VSpeed.toFixed(2)} m/s,
            W Speed: ${this.WSpeed.toFixed(2)} m/s,
            Flux: ${this.flux.toFixed(2)},
            Temperature: ${this.temperature.toFixed(2)} °C,
            Salinity: ${this.salinity.toFixed(2)} PSU,
            Colorants: ${this.colorants.toFixed(2)}
        }`;
    }
}

// NOTE: 带索引的水质模型数据
// 水质模型数据类，继承自 WaterDataWithIndex
export class WaterQualityDataWithIndex extends WaterDataWithIndex {
    // 构造函数和类属性（省略以减少重复）

    // I J 层次 CHC CHG CHD ROC LOC DOC ROP LOP DOP P4D RON LON CON NHX NOX SUU SAA COD DOX TAM FCB TN TP CODMN CHL ZMD X Y Z
    constructor(
        index: number = 0,
        i: number = 0,
        j: number = 0,
        layer: number = 0,
        CHC: number = 0,
        CHG: number = 0,
        CHD: number = 0,
        ROC: number = 0,
        LOC: number = 0,
        DOC: number = 0,
        ROP: number = 0,
        LOP: number = 0,
        DOP: number = 0,
        P4D: number = 0,
        RON: number = 0,
        LON: number = 0,
        CON: number = 0,
        NHX: number = 0,
        NOX: number = 0,
        SUU: number = 0,
        SAA: number = 0,
        COD: number = 0,
        DOX: number = 0,
        TAM: number = 0,
        FCB: number = 0,
        TN: number = 0,
        TP: number = 0,
        CODMN: number = 0,
        CHL: number = 0,
        ZMD: number = 0,
        X: number | null = null,
        Y: number | null = null,
        Z: number | null = null
    ) {
        super(index, i, j, layer, X, Y, Z); // 调用父类构造函数
        this.CHC = CHC;
        this.CHG = CHG;
        this.CHD = CHD;
        this.ROC = ROC;
        this.LOC = LOC;
        this.DOC = DOC;
        this.ROP = ROP;
        this.LOP = LOP;
        this.DOP = DOP;
        this.P4D = P4D;
        this.RON = RON;
        this.LON = LON;
        this.CON = CON;
        this.NHX = NHX;
        this.NOX = NOX;
        this.SUU = SUU;
        this.SAA = SAA;
        this.COD = COD;
        this.DOX = DOX;
        this.TAM = TAM;
        this.FCB = FCB;
        this.TN = TN;
        this.TP = TP;
        this.CODMN = CODMN;
        this.CHL = CHL;
        this.ZMD = ZMD;
    }
    public CHC:number;
    public CHG:number;
    public CHD:number;
    public ROC:number;
    public LOC:number;
    public DOC:number;
    public ROP:number;
    public LOP:number;
    public DOP:number;
    public P4D:number;
    public RON:number;
    public LON:number;
    public CON:number;
    public NHX:number;
    public NOX:number;
    public SUU:number;
    public SAA:number;
    public COD:number;
    public DOX:number;
    public TAM:number;
    public FCB:number;
    public TN: number;
    public TP: number;
    public CODMN:number ;
    public CHL:number ;
    public ZMD:number ;

    // 定义 toString() 方法
    toString(): string {
        return `WaterQualityDataWithIndex {
            ${super.toString()},
            CHC: ${this.CHC.toFixed(2)},
            CHG: ${this.CHG.toFixed(2)},
            CHD: ${this.CHD.toFixed(2)},
            ROC: ${this.ROC.toFixed(2)},
            LOC: ${this.LOC.toFixed(2)},
            DOC: ${this.DOC.toFixed(2)},
            ROP: ${this.ROP.toFixed(2)},
            LOP: ${this.LOP.toFixed(2)},
            DOP: ${this.DOP.toFixed(2)},
            P4D: ${this.P4D.toFixed(2)},
            RON: ${this.RON.toFixed(2)},
            LON: ${this.LON.toFixed(2)},
            CON: ${this.CON.toFixed(2)},
            NHX: ${this.NHX.toFixed(2)},
            NOX: ${this.NOX.toFixed(2)},
            SUU: ${this.SUU.toFixed(2)},
            SAA: ${this.SAA.toFixed(2)},
            COD: ${this.COD.toFixed(2)},
            DOX: ${this.DOX.toFixed(2)},
            TAM: ${this.TAM.toFixed(2)},
            FCB: ${this.FCB.toFixed(2)},
            TN: ${this.TN.toFixed(2)},
            TP: ${this.TP.toFixed(2)},
            CODMN: ${this.CODMN.toFixed(2)},
            CHL: ${this.CHL.toFixed(2)},
            ZMD: ${this.ZMD.toFixed(2)}
        }`;
    }
    getAttributesList():string[]{
        return [
            "Index",'i','j',
            'CHC','CHG','CHD','ROC','LOC','DOC','ROP','LOP','DOP','P4D','RON','LON','CON','NHX','NOX','SUU','SAA','COD','DOX','TAM','FCB','TN','TP','CODMN','CHL','ZMD',
            'X','Y','Z'
        ];
    }
}

export class Point {
    constructor(public x: number = 0, public y: number = 0, public z: number = 0) {}

    // 加法方法
    add(other: Point): Point {
        return new Point(this.x + other.x, this.y + other.y, this.z + other.z);
    }

    // 减法方法
    subtract(other: Point): Point {
        return new Point(this.x - other.x, this.y - other.y, this.z - other.z);
    }

    // 可选：提供一个toString方法用于显示
    toString(): string {
        return `(${this.x}, ${this.y}, ${this.z})`;
    }
    
    toArray():Array<number>{
        return [this.x,this.y,this.z];
    }
}

export class Point2D {
    constructor(public x: number = 0, public y: number = 0) {}

    // 加法方法
    add(other: Point): Point {
        return new Point(this.x + other.x, this.y + other.y);
    }

    // 减法方法
    subtract(other: Point): Point {
        return new Point(this.x - other.x, this.y - other.y);
    }

    // 可选：提供一个toString方法用于显示
    toString(): string {
        return `(${this.x}, ${this.y})`;
    }
    
    toArray():Array<number>{
        return [this.x,this.y];
    }
}